package com.ccy.net;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 对线程池的封装，核心方法是提交任务
 */
public class WeatherEngine {

	private Executor mThreadPool;

	public WeatherEngine() {
		mThreadPool = getDefaultThreadPool();
	}

	protected ExecutorService getDefaultThreadPool() {
		return Executors.newCachedThreadPool();
	}
	
	public void submit(LoadWeatherTask loadWeatherTask) {
		mThreadPool.execute(loadWeatherTask);
	}

	public void stop() {
		((ExecutorService)mThreadPool).shutdown();
	}
}
